﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SimpleData.ObjectModel;
using System.Diagnostics.Contracts;

namespace SimpleData.Storage.Common
{
	/// <summary>
	/// Representa uma linha de dados
	/// </summary>
	public class DataObjectRow
	{
		private List<DataObjectColumn> values = new List<DataObjectColumn>();

		public DataObjectRow( DataObjectColumnKey key, SchemaName entity )
		{
			Contract.Requires<ArgumentNullException>( key != null, "key" );
			Contract.Requires<ArgumentNullException>( entity != null, "entity" );

			this.Key = key;
			this.EntitySchema = entity;
		}

		/// <summary>
		/// Obtém a chave que representa a coluna
		/// </summary>
		public DataObjectColumnKey Key
		{ get; private set; }

		/// <summary>
		/// Obtém o schema que define como representa cada linha
		/// </summary>
		public SchemaName EntitySchema
		{ get; set; }

		/// <summary>
		/// Obtém os valores de cada coluna já serializado
		/// </summary>
		public IEnumerable<DataObjectColumn> Values
		{ get; private set; }

		public DataObjectColumn AddColumn( FieldName field, byte[] value )
		{
			DataObjectColumn column = new DataObjectColumn( field, value );
			this.values.Add( column );
			return column;
		}
	}
}
